package operation;

import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2024-05-25
 * Time: 19:52
 */
public class DelBook implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("删除图书....");
        System.out.println("请输入书名：");
        Scanner sc = new Scanner(System.in);
        String fname = sc.nextLine();
        for (int i = 0; i < bookList.getEffnum(); i++) {
            if (bookList.getBooks(i).getName().equals(fname)) {
                for (int j = i; j < bookList.getEffnum() - 1; j++) {
                    bookList.setBooks(bookList.getBooks(j + 1), j);
                }
                bookList.setEffnum(bookList.getEffnum() - 1);
                System.out.println("删除成功！！！");
                return;
            }
        }
        System.out.println("没有这本书！！！");

    }
}
